﻿using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using ChangDiTools.Tool;
namespace ChangDiTools.Demo {
    public class Views {
        [CommandMethod("ZoomScaled")]
        public static void ZoomScaled() {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.ZoomScaled(2);
        }
        [CommandMethod("ZoomWindow")]
        public static void ZoomWindow() {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptPointResult pt1 = ed.GetPoint("\n输入第一个角点");
            if (pt1.Status != PromptStatus.OK) return;

            PromptCornerOptions pco=new PromptCornerOptions("\n输入第二个角点", pt1.Value);
            PromptPointResult pt2 = ed.GetCorner(pco);
            if (pt2.Status != PromptStatus.OK)  return;
            ed.ZoomWindow(pt1.Value, pt2.Value);
        }

        [CommandMethod("ZoomObject")]
        public static void ZoomObject() {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptEntityResult per = ed.GetEntity("\n请选择对象");
            if (per.Status != PromptStatus.OK) {
                return;
            }

            ed.ZoomObject(per.ObjectId);
        }

        [CommandMethod("ZoomExt")]
        public static void ZoomExt() {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            ed.ZoomExtents();
        }
    }
}
